package tables

import "html/template"

var wangEditor template.HTML = `
<!--
<link href="https://unpkg.com/@wangeditor/editor@latest/dist/css/style.css" rel="stylesheet">
<link href="/wangeditor/wangeditor5.min.css" rel="stylesheet" />
-->
<style>
  #editor—wrapper {
    border: 1px solid #ccc;
    z-index: 100; /* 按需定义 */
  }
  #toolbar-container {
    border-bottom: 1px solid #ccc;
  }
  #editor-container {
    height: 500px;
  }
</style>
<div id="markdown-container" style="height: 100%;"></div>
<div id="editor-wrapper" style="display: none;height: 100%;">
  <div style="display: flex;height: 100%;overflow: auto;flex-direction: column;">
    <div id="toolbar-container"><!-- 工具栏 --></div>
    <div id="editor-container" name={{ .Field }} value="{{ .Value }}" style="flex:1"><!-- 编辑器 --></div>
  </div>
</div>

<!-- 引入 js -->
<!--
<script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script>
<script src="/wangeditor/wangeditor5.min.js"></script>
-->
 <script>
	const { createEditor, createToolbar,i18nChangeLanguage } = window.wangEditor
var locale='zh-CN'
		if (locale!='zh-CN'){ //如果不是中文,就使用英文
			// 切换语言 - 'en' 或者 'zh-CN'
			i18nChangeLanguage('en')
		}
		var content = "";
		const editorConfig = {
			placeholder: '{{ "Please enter content..."}}',
			MENU_CONF: {},
			onChange(editor) {
				content = editor.getHtml()
				// 也可以同步到 <textarea>
			},
		}
		// var editorUploadConfig = {
		// 	 async customUpload(file, insertFn) {
		// 		funcFileUpload(file,insertFn);
		// 	},
		// };
		// editorConfig.MENU_CONF['uploadImage'] = editorUploadConfig;
		// editorConfig.MENU_CONF['uploadVideo'] = editorUploadConfig;
		const editor = createEditor({
			selector: '#editor-container',
			html: '<p></p>',
			config: editorConfig,
			mode: 'default', // or 'simple'
		})
		const toolbar = createToolbar({
			editor,
			selector: '#toolbar-container',
			config: { excludeKeys: ['todo','divider','redo'] },
			mode: 'default', // or 'simple'
		})
		editor.dangerouslyInsertHtml({{ .Value}})
</script>
`